#ifndef _M1_API_H_
#define _M1_API_H_

#include "m1cmd.h"

extern U08	M1Key[16][8];
extern U08  gM1_Publish_00[16];	
extern U08  gM1CardSN[8];

/*
**************************************************************************************************************
*										  常 量
**************************************************************************************************************
*/
#define M1_SECTOR_00	(  0 )
#define M1_SECTOR_01	(  1 )
#define M1_SECTOR_02	(  2 )
#define M1_SECTOR_03	(  3 )
#define M1_SECTOR_04	(  4 )
#define M1_SECTOR_05	(  5 )
#define M1_SECTOR_06	(  6 )
#define M1_SECTOR_07	(  7 )
#define M1_SECTOR_08	(  8 )
#define M1_SECTOR_09	(  9 )
#define M1_SECTOR_10	( 10 )
#define M1_SECTOR_11	( 11 )
#define M1_SECTOR_12	( 12 )
#define M1_SECTOR_13	( 13 )
#define M1_SECTOR_14	( 14 )
#define M1_SECTOR_15	( 15 )

#define DEF_CZ_MiOneCard_Debug  DEF_SysCard_Debug 

extern void CurCalc_DataCpy( U08 *outbuf, U08 *inbuf, U32 insize );			//数据复制

extern void CurCalc_DataSet( U08 *outbuf, U08 indata, U32 insize );			//数据设置
extern U32  CurCalc_DataCmp( U08 *inbuf1, U08 *inbuf2, U32 insize );		//数据比较

extern U32 MiOne_GetPsamKey( U08 *p_CardSN, U08 *buf );

extern U32 BD_MiOne_GetPsamKey( U08 *p_CardSN, U08 *buf, U08 *Sectors, U32 secsize );

extern U32 AH_M1Card_ReadAllData_BD( U08 *p_CardSN, U08 *buf, U32 *succ_cout );
extern U32 AH_M1Card_ReadAllData_20( U08 *p_CardSN, U08 *buf, U32 *succ_cout );

extern void AH_M1Card_PrintAllData( void );


//==========================================
extern U32 AH_M1Card_ReadPublish( U08 *p_CardSN, U08 *buf, U08 ver );

extern U32 AH_M1Card_ReadCommInfo( U08 *buf );

extern U32 AH_M1Card_WriteCommInfo( U08 *buf );

extern U32 AH_M1Card_WriteRecFile( U08 *p_CardSN, U08 recno, U08 *recbuf );

extern U32 AH_M1Card_ReadRecFile( U08 *p_CardSN, U08 recno, U08 *recbuf );

extern U32 WriteCardCoutWallet( U32 money, U32 *newmoney, U08 *combuf, U08 *recbuf, U32 sect );

extern U32 ReadCardWalletErrPro( U32 sector, U08 *combuf );

extern U32 AH_M1Card_ReadCardWallet( U32 *wallet, U08 *combuf );

extern U32 AH_M1Card_WriteCardWallet( U32 money, U32 *newmoney, U08 *combuf, U08 *recbuf );

extern U32 AH_M1Card_WriteCardNumWallet( U32 money, U32 *newmoney, U08 *combuf, U08 *recbuf );

extern U32 AH_M1Card_WriteCardState( U08 *p_CardSN, U08 cardstate );


#endif